Method and apparatus for determining misalignment

ABSTRACT

An apparatus for determining misalignment between a first image and a second image, the first and second images being viewable stereoscopically, the apparatus comprising:
     a determiner operable to determine a feature position within the first image and a corresponding feature position within the second image;   a definer operable to define, within the first image and the second image, the optical axis of the cameras capturing said respective images;   a calculator operable to calculate the misalignment between the feature position within the first image and the corresponding feature position within the second image using a model, the misalignment being determined in dependence upon the location of the feature position of the first image and the corresponding feature position of the second image relative to the defined optical axis of the respective images; and   a tester operable to test the validity of the calculated misalignment using a random sample consensus technique, whereby the tested misalignment is valid when the random sample consensus technique achieves a predetermined condition.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to a method and apparatus for determining misalignment.

2. Description of the Prior Art

When shooting stereo video to view as a 3D image, it is common practice to shoot this footage using two cameras. In order to ensure that the footage is captured correctly, the cameras should have a similar level of zoom and minimal vertical parallax. Also, the misalignment of roll of the cameras should be minimal.

Normally, this would be corrected, where possible by a camera operator. Usually misalignment between the two cameras does not manifest itself as any one of the above errors, but is usually a combination of two or more misalignments. This makes it difficult for a camera operator to establish and correct the misalignment. Moreover, it is important that such errors are corrected quickly and accurately, particularly for live video footage.

It is an aim of embodiments of the present invention to address this issue.

SUMMARY OF THE INVENTION

According to a first aspect of the present invention, there is provided a method of determining misalignment between a first image and a second image, the first and second images being viewable stereoscopically, the method comprising: determining a feature position within the first image and a corresponding feature position within the second image; defining, within the first image and the second image, the optical axis of the cameras capturing said respective images; calculating the misalignment between the feature position within the first image and the corresponding feature position within the second image using a model, the misalignment being determined in dependence upon the location of the feature position of the first image and the corresponding feature position of the second image relative to the defined optical axis of the respective images; and testing the validity of the calculated misalignment using a random sample consensus technique, whereby the tested misalignment is valid when the random sample consensus technique achieves a predetermined condition.

The misalignment may be valid when the probability of the correct misalignment is above a threshold.

The predetermined condition may be a predetermined number of iterations of the random sample consensus technique.

The number of iterations may be determined according to the equation

$n = \frac{\log\left( {1 - {{target\_ incorrect}{\_ est}{\_ prob}}} \right)}{\log\left( {1 - {incorrect} - {est\_ prob}} \right)}$ Where target_incorrect_est_prob is the probability of the model being incorrect and incorrect_est_prob is probability of the corresponding feature point being incorrect.

The model may be defined by the equation y=S·(xL·sin θ+yL·cos θ)+T

where y is the vertical position of the feature point in the second image; xL and yL are the respective horizontal and vertical positions of the feature point in the first image; θ is the roll angle; S is the scale metric and T is the vertical mismatch metric between the two images.

The model may comprise obtaining feature points from downscaled versions of an original first and second image using a block match technique.

The method may further comprise using the feature points obtained from the downscaled versions of the original first and second image as a starting point for a block match technique in the original first and second image and obtaining the first and second feature points from the original first and second image.

The method may further comprise defining within the first image at least one further feature position, and at least one further corresponding feature position within the second image, wherein the vertical translation is calculated by: selecting two feature positions in the first image and a corresponding two feature positions within the second image; and determining the vertical translation in accordance with a given roll misalignment between the first and second images.

The feature position in the first image and the corresponding feature position in the second image may be located above the defined optical axis and the further feature position in the first image and the corresponding feature position in the second image are located below the defined optical axis.

The scale may be calculated by: selecting a feature position in the first image and a corresponding feature position within the second image; and determining the scale in accordance with a given vertical translation between the first and second images.

The feature position in the first image and the corresponding feature position in the second image may be located above the defined optical axis or the feature position in the first image and the corresponding feature position in the second image is located below the defined optical axis.

The method may further comprise defining within the first image at least one further feature position, and at least one further corresponding feature position within the second image, wherein the roll is calculated by: selecting two feature positions in the first image and a corresponding two feature positions within the second image; and determining the roll in accordance with a given scale misalignment between the first and second images.

The feature position in the first image and the corresponding feature position in the second image may be located to the left of the defined optical axis and the further feature position in the first image and the corresponding feature position in the second image are located to the right of the defined optical axis.

The feature position and the further feature position may be generated randomly.

The feature position may be a pixel position in the respective first and second image.

According to a further aspect there is provided a computer program containing computer readable instructions which, when loaded onto a computer, configure the computer to perform a method according to any one of the above.

According to a further aspect, there is provided a storage medium configured to store the computer program of claim 16 therein or thereon.

According to a further aspect, there is provided an apparatus for determining misalignment between a first image and a second image, the first and second images being viewable stereoscopically, the apparatus comprising: a determiner operable to determine a feature position within the first image and a corresponding feature position within the second image; a definer operable to define, within the first image and the second image, the optical axis of the cameras capturing said respective images; a calculator operable to calculate the misalignment between the feature position within the first image and the corresponding feature position within the second image using a model, the misalignment being determined in dependence upon the location of the feature position of the first image and the corresponding feature position of the second image relative to the defined optical axis of the respective images; and a tester operable to test the validity of the calculated misalignment using a random sample consensus technique, whereby the tested misalignment is valid when the random sample consensus technique achieves a predetermined condition.

The misalignment may be valid when the probability of the correct misalignment is above a threshold.

The predetermined condition may be a predetermined number of iterations of the random sample consensus technique.

The number of iterations may be determined according to the equation

$n = \frac{\log\left( {1 - {{target\_ incorrect}{\_ est}{\_ prob}}} \right)}{\log\left( {1 - {incorrect} - {est\_ prob}} \right)}$ Where target_incorrect_est_prob is the probability of the model being incorrect and incorrect_est_prob is probability of the corresponding feature point being incorrect.

The model may be defined by the equation y=S·(xL·sin θ+yL·cos θ)+T

where y is the vertical position of the feature point in the second image; xL and yL are the respective horizontal and vertical positions of the feature point in the first image; θ is the roll angle; S is the scale metric and T is the vertical mismatch metric between the two images.

The apparatus may further comprise an obtainer operable to obtain feature points from downscaled versions of an original first and second image using a block match technique.

The apparatus may use the feature points obtained from the downscaled versions of the original first and second image as a starting point for a block match technique in the original first and second image and obtaining the first and second feature points from the original first and second image.

The definer may be further operable to define within the first image at least one further feature position, and at least one further corresponding feature position within the second image, wherein the vertical translation is calculated by: selecting two feature positions in the first image and a corresponding two feature positions within the second image; and determining the vertical translation in accordance with a given roll misalignment between the first and second images.

The feature position in the first image and the corresponding feature position in the second image may be located above the defined optical axis and the further feature position in the first image and the corresponding feature position in the second image are located below the defined optical axis.

The scale may be calculated by: selecting a feature position in the first image and a corresponding feature position within the second image; and determining the scale in accordance with a given vertical translation between the first and second images.

The feature position in the first image and the corresponding feature position in the second image may be located above the defined optical axis or the feature position in the first image and the corresponding feature position in the second image is located below the defined optical axis.

The definer may be operable to define within the first image at least one further feature position, and at least one further corresponding feature position within the second image, wherein the roll is calculated by: selecting two feature positions in the first image and a corresponding two feature positions within the second image; and determining the roll in accordance with a given scale misalignment between the first and second images.

The feature position in the first image and the corresponding feature position in the second image may be located to the left of the defined optical axis and the further feature position in the first image and the corresponding feature position in the second image are located to the right of the defined optical axis.

The feature position and the further feature position may be generated randomly.

The feature position may be a pixel position in the respective first and second image.

BRIEF DESCRIPTION OF THE DRAWINGS

The above and other objects, features and advantages of the invention will be apparent from the following detailed description of illustrative embodiments which is to be read in connection with the accompanying drawings, in which:

FIG. 1 shows a camera arrangement connected to a misalignment metric calculator according to an embodiment of the present invention;

FIG. 2 shows the misalignment metric calculator of FIG. 1;

FIG. 3 shows a flow diagram explaining the process carried out by an edge detector and a correspondence point determiner in the misalignment metric calculator of FIG. 1;

FIG. 4 shows a graphical narration of the flow diagram of FIG. 3;

FIG. 5 shows a flow diagram explaining the calculation of the misalignment metrics;

FIG. 6 shows a flow diagram explaining the principle for determining the vertical translation metric;

FIG. 7 shows a method for converting the pixel positions into pixel positions relative to the optical axis;

FIG. 8 shows a flow diagram explaining the principle for determining the Scale metric;

FIG. 9 shows a flow diagram explaining the principle for determining the roll metric;

FIG. 10 shows a diagram explaining the determination of the vertical translation metric algorithm;

FIGS. 11 and 12 show diagrams explaining the determination of the roll metric algorithm; and

FIGS. 13A and 13B show a flow diagram describing a technique for accurately defining the correspondence points.

DESCRIPTION OF EXAMPLE EMBODIMENTS

Overall Method

In embodiments, to calculate the alignment metrics for stereo images, the following broad method is performed:

-   -   1) Key feature points in one of the two images are selected. In         embodiments, the key feature points in the left image are         selected.     -   2) The key feature points are used as the basis for a block         matching process to determine the corresponding key feature         points in the right hand image.     -   3) A series of geometric calculations is performed to yield         three metrics of distortion. Specifically, a metric indicating         the vertical disparity is determined, a metric indicating the         scale disparity in determined and finally a metric indicating         roll disparity is determined. In embodiments, the metric         determined in the previous step is used in the calculation of         the metric in the subsequent step. Although, this discussion         indicates that the three metrics are determined in a particular         order, the invention is not so limited as will be explained         hereinafter. The metrics can be calculated in any order. The         metrics may then be used either to adjust the physical position         of the camera and/or parameters of the camera or may be used to         electronically adjust the captured image to take account of the         misalignment.

FIG. 1 shows an implementation of embodiments of the present invention. Two cameras 110 and 120 are set up in a stereoscopic mariner. Together, the stereoscopic cameras form a camera arrangement 100. The output from each camera is fed into a misalignment metric calculator 200 according to embodiments of the present invention. The metric calculator 200 determines the amount of misalignment between the two cameras in the arrangement 100. It should be noted here that cameras set up to capture stereoscopic images must have horizontal displacement, however, it is not essential for this algorithm for the images to have horizontal displacement. Therefore, the metric calculator 200 determines a metric indicating the vertical disparity, a metric indicating the roll disparity and a metric determining the scale disparity is produced. These metrics may be used by a camera operator to physically correct the alignment of the cameras or may be used to control a servo motor to correct the alignment. Indeed, the metrics may also be used to electronically correct the images produced by the camera arrangement 100 without any physical correction of the camera orientation.

FIG. 2 shows the metric calculator 200 in more detail. The size of the images from the two cameras are first reduced to ¼ HD (i.e. to 480×270 resolution or 360×180 from 1280×720p) using a conventional technique and then fed into an edge detector 210. Reducing the resolution of the image means that edge detection can be performed more quickly. The edge detector 210 is used to determine the horizontal edges in the left hand image. The detected edges are then fed to a correspondence point determiner 220 which determines points in the right hand image which correspond to points in the left hand image. In other words, the correspondence point determiner 220 determines where in the left hand image certain pixels from the right hand image are located. The metrics are calculated in the metric determiner 230 and output.

FIG. 3 provides a flow diagram explaining the process carried out by the edge detector 210 and the correspondence point determiner 220. This flow diagram is narrated using the images in FIG. 4.

In FIG. 4, the left hand image 120A (captured by the left hand camera 120) contains an image of a car 125A. This is first reduced to ¼ HD resolution using a conventional technique. Reducing the resolution means that edge detection can be performed more quickly. In step S2101 of FIG. 3, the horizontal edges in the left hand image are detected. In embodiments, this could be achieved using an edged detect algorithm such as a Sobel edge detection algorithm for example. The reason the horizontal edges are detected is because one of the metrics to be calculated is the vertical displacement between the two images. Thus, by calculating only the horizontal edges, the number of candidate feature points is reduced without substantially impacting on the accuracy of the results.

After the horizontal edges in the left hand image are calculated, an image similar to 120B (see FIG. 4) is produced. As can be seen from FIG. 4, an erroneous edge 125B is produced. This does not have a corresponding point in the right hand image. Accordingly, it is desirable to reduce the number of detected horizontal edges. The reduction in the number of horizontal edges takes place in step S2102 of FIG. 3. In order to achieve this, the edge detected image is divided into tiles. In embodiments, each tile is 16 pixels wide by 16 pixels high. One tile 125C is shown in FIG. 4. However, any size of tile may be selected. Similarly, any shape of tile may be selected so that the tiles are, for example, rectangular in shape. Any edges that do not transcend a tile are ignored. In other words, detected edges which are less than 16 pixels long are ignored. By performing this reduction, spurious and erroneous edges are ignored. This improves the reliability of the results as well as reduces the computational expense of the method.

After the number of detected edges is reduced, the image is divided into quadrants. The centre of the quadrant is the optical axis of the image. The reason that, in embodiments, the quadrant is centred on the optical axis is because the optical axis is linearly invariant. In other words, the optical axis is not affected by scale and roll distortion. For ease of explanation, it is assumed that the optical axis of the image is the centre of the image. However, the skilled person will understand that although this is a very valid assumption, this is not always the case. This is shown in 120D in FIG. 4, where one quadrant 125D is highlighted.

After the image has been divided into quadrants, a sample number of edge pixels are selected from each quadrant. In embodiments, 20 pixels are selected from each quadrant although the invention is not so limited and any number of pixels may be selected. This selection may be based on a balance between accuracy and speed of computation as would be appreciated. Further, in embodiments, the pixels are selected randomly, although the invention is not so limited.

A typical image where a selected number of pixels have been selected is shown at 120E in FIG. 4. One such pixel position is highlighted at 125E. It should be noted that a pixel position is defined as a suitable feature point, but the invention is not so limited. Other feature points such as a sub-pixel position in the ¼ resolution image may also be determined as would be appreciated. As any one of a number of sub-pixels can exist at a “normal” pixel position (i.e. a pixel position of a full resolution HD signal), the value of the sub-pixel may be selected randomly or by some other method. Further, a user could be informed of the different possible sub-pixel values at the “normal” pixel position.

The method so far has identified feature positions in the left hand image. These feature positions are pixel positions in the left hand image. It is now necessary to determine where corresponding pixels positions in the right hand image exist.

A search is carried out at each defined pixel position in the right hand image. In other words, as the position of a number of pixel positions are defined in the left hand image, a search needs to be carried out around the same pixel position in the right hand image to determine where a corresponding pixel is positioned. This is achieved using a block matching technique.

In step S2104 a conventional block matching technique is carried out at each pixel position in the right hand image to determine the corresponding pixel position. An illustration of this is shown in FIG. 4 at 110B. As is seen in image 110B, the pixel position 125E derived from the left hand image forms the centre of a search area in the right hand image 110B. The size of the search area must accommodate misalignments due to errors as well as the deliberate horizontal displacement required to achieve stereoscopic viewing. So, if the image was a typical full resolution image, the search area is 250 pixels wide by 100 pixels high. However, the invention is not so limited and other size and shape search areas may be used. Specifically, for ¼ resolution, the search area is 63 pixels wide×45 pixels high.

The result of the block matching technique is a map of probabilities which provide the probability of each pixel position in the search area corresponding to the pixel position 125E defined in the left hand image. The pixel position in the right hand image having the highest probability is selected as being the pixel position in the right hand image corresponding to the pixel position in the left hand image 125E. As is seen in FIG. 4, the pixel position in the right hand image is defined as pixel position 119B. This is repeated for all the pixel positions defined in the left hand image as noted in step S2105.

In order to ensure that the number of erroneous results is reduced, the results from step S2105 are filtered. As a first filter, as a definite corresponding pixel position in the right hand image should have a probability of 1, all results below a certain threshold of, for example, 0.98 (or 98% certainty) are ignored. This reduces the number of erroneous results. As this is an example threshold, other suitable thresholds are envisaged and the invention is not so limited.

Further, as the pixel positions in the left hand image are edge pixel positions, the corresponding points in the right hand image should also be edge pixel positions. Therefore, the right hand image is also subjected to an edge detect algorithm such as Sobel edge detection algorithm to detect the horizontal edges. If the corresponding pixel position in the right hand image is located on one of these horizontal edges, then there is an increased probability that the pixel position in the right hand image does correspond to the pixel position determined in the left hand image. It should be noted that either or both of these techniques can be used to reduce the likelihood of erroneous results. Indeed, a combination of both techniques may also be used.

Referring to FIG. 2, the output from the correspondence point determiner 220 is a list of pixel positions in the left hand image and a list of corresponding points in the right hand image.

In order to improve the accuracy of the correspondence point determiner 220, the block matching technique is repeated using the full resolution (1920×1080) image where the correspondence points were identified. Specifically, the block matching technique is repeated using a 16 pixel×16 pixel search window in the left image and a 32 pixel×32 pixel search window in the right image. The centre of each search window is positioned at the point determined by the correspondence point determiner 220. The results of the full resolution block matching are fed into the metric calculator 230. Although the foregoing has been explained, a conventional technique for determining positions in one image and corresponding points in a second image may equally be used. However, it should be noted here that the aforementioned method is quicker and less computationally expensive than more conventional techniques such as Scale-Invariant Feature Transform (SIFT).

Calculation of Metrics

After the correspondence feature points have been derived and converted into positions relative to the optical axis of the images, a method of deriving the metrics as below may be used.

Referring to FIG. 10, if we make the assumption that the vertical offset is fixed, so that the vertical offset is invariant to scale and roll rotation, it can be seen that y2_(r) =S·(x2_(l)·sin θ+y2_(l)·cos θ)+T  [1]

where y2_(r) is the vertical position of point p2_(r) (relative to the optical axis); x2_(l) and y2_(l) are the respective horizontal and vertical positions of point p2_(l); θ is the roll angle; is the scale metric and T is the vertical mismatch metric between the two images.

Additionally, it is possible to measure the difference in vertical position between points p2_(l) and p2_(r), d, by using block matching.

In other words, d=y2_(r) −y2_(l)  [2]

Accordingly, using [1] and [2], it is apparent that T=y2_(l)(1−S·cos(θ))−x2_(l) ·S·sin(θ)+d T=a·y2_(l) −b·x2_(l) +d  [3] where a=1−S·cos(θ)  [4] and b=S·sin(θ)  [5]

As there are three unknown parameters, T, scale and θ (or T, a and b), it is possible to find these values using 3 points, having co-ordinates (x,y) described relative to the optical axis, in the left image, p1_(l), p2_(l) and p3_(l) and corresponding points in the right image, it is possible to show that

$b = \frac{{\left( {y_{l\; 1} - y_{l\; 3}} \right)\left( {d_{2} - d_{1}} \right)} - {\left( {y_{l\; 1} - y_{l\; 2}} \right)\left( {d_{3} - d_{1}} \right)}}{{\left( {y_{l\; 1} - y_{l\; 3}} \right)\left( {x_{l\; 1} - x_{l\; 2}} \right)} - {\left( {y_{l\; 1} - y_{l\; 2}} \right)\left( {x_{l\; 1} - x_{l\; 3}} \right)}}$ and $a = \frac{\left( {d_{3} - d_{1}} \right) - {b\left( {x_{l\; 1} - x_{l\; 3}} \right)}}{\left( {y_{l\; 1} - y_{l\; 3}} \right)}$

From [3], [4] and [5], it is apparent that T, θ and S can be established

If more than 3 feature points are measured, in embodiments it is possible to list the points in order descending the image (i.e. from top to bottom of the image). Three of these correspondences are selected. The three points to be selected are the ith, ith+n/3 and ith+2n/3 feature points, where i is the iteration of the feature point selection (between 0 and n/3−1) and n is the number of feature points measured. The values of a, b and T are calculated for each iteration and after all the iterations have taken place, the values are ordered. The median value of a, b and T is selected as the best estimate and these values are used to calculate T, scale and θ.

Referring to FIGS. 13A and 13B, a method of more accurately establishing the θ, scale and T metric noted above is disclosed. As there is an error in establishing the accuracy of the correspondence points, the accuracy of the θ, scale and T will be erroneous. Therefore, it is desirable to reduce the inaccuracy when establishing the correspondence points and thus the inaccuracy of the calculated metrics. In order to improve the accuracy of the calculated metrics, a RANSAC (RANdom SAmple Consensus) method is used to establish the 3 correspondence points required to calculate the θ, scale and T. FIGS. 13A and 13B show a flowchart describing such a method.

The method is started at step S1305. In step S1310, the number of iterations of the RANSAC technique is calculated. The number of iterations required depends on the accuracy of the required results as well as the accuracy of the correspondence points. Typically, the probability of any one correspondence point being correct is around 80% for high performing correspondence algorithms such as a SIFT, SURF or block matching (or the probability of the correspondence point being incorrect is 20%).

In order to calculate the number of iterations n required, a probability of the correspondence points being correct after the RANSAC technique is determined. In embodiments this is 99.9999% likelihood of the θ, scale and T values being correct. Therefore,

$n = \frac{\log\left( {1 - {{target\_ incorrect}{\_ est}{\_ prob}}} \right)}{\log\left( {1 - {incorrect} - {est\_ prob}} \right)}$

Where target_incorrect_est_prob is the probability of the θ, scale and T values being incorrect and incorrect_est_prob is probability of the correspondence point being incorrect.

After the value n has been determined, 3 correspondence points in the left image are randomly selected. Further the corresponding points in the right hand image are also established. This is step S1315. These selected points are used to calculate the θ, scale and T in the equations noted above. This is step S1320. The randomly selected points are added to a consensus set in step S1325.

All the other correspondence points are then individually inserted into the model to calculate the position of the points in the right hand image and the distance between the predicted and measured position calculated using θ, scale and T values. These established values are compared against those values determined by the randomly selected correspondence points (step S1335). If the difference between the values is below a threshold, then the correspondence points are added to the consensus set (S1340). If the difference is above a threshold, then the point is not added to the consensus set (S1345).

After all the correspondence points have been tested, the number of points in the consensus set is counted. If the number of points is above a threshold, of say, the same or less than the accuracy of the point correspondence algorithm, then a median of values method is used over the consensus set to generate a better model S1355A. That model is tested again with all the correspondence points (S1360). If, however, the number of points in the consensus set is below the threshold, another 3 consensus points are randomly selected and the procedure repeats (S1355).

As noted before, the model is tested against a previous model using all the correspondence points in the consensus set. If the differences between the model under test and the previous model are below an error threshold, then the model under test is determined to be a better model than previously (S1365). If the model is not better than the previous model, the model under test is ignored (S1370).

If the model under test is better than before, the consensus set, model and error values are stored (S1375) for use in the next iteration. The error value is compared to a threshold error and if the error is below a threshold value, the RANSAC process is stopped. Alternatively, if the error is above a threshold, but the number of iterations of the RANSAC process is below n, another 3 correspondence points are randomly selected. However, if the error is above the threshold and the number of iterations is above n, the RANSAC process ends. It should be noted here that the overall threshold abort technique (step S1380) may or may not be used. In embodiments, this step my not be included.

At the end of the RAN SAC process, the output roll, scale and T value is established.

FIG. 5 shows a flow diagram explaining a different method of calculating the metrics after the corresponding points have been determined.

As will be noted from the structure of the algorithm, the values of the metrics in this embodiment are calculated iteratively. During each iteration of the algorithm, the values of the metrics begin to converge to a steady value. It should be noted here that the algorithm is run in real-time. This means that for one frame of video, the algorithm may not reach the required steady state. If this is the case, then the algorithm is run over a number of different frames. This is because the misalignment is unlikely to change over a small number of frames required until a steady state is reached. It should be noted that if the metric algorithm is required to be run for another frame of video, the correspondence algorithm described in FIG. 3 will need to be run for the new frame of video. Whereas, if the steady state is reached during one frame of video, the correspondence algorithm of FIG. 3 needs to be run only once.

After the steady state is reached, the algorithm may be run periodically, for example once every 10 seconds or after a predetermined number of frames, to ensure that the cameras have not become misaligned. Alternatively, the algorithm may be run after the focal length of the cameras has changed or in response to any other action.

In step S501, before a first iteration of the calculation of the metrics, the roll metric is set to be 0°. This value of the roll metric will be updated during the first iteration of the metric calculation algorithm. The reason that the roll metric is set to 0° in preference to any other assumed value of a metric is because the roll metric will be close to zero. This is because during the initial set-up by the camera operator, the roll difference is likely to be small due to the effect of mismatch in the roll on the image. Therefore, by making the initial assumption that the roll metric is 0°, the accuracy of the other metrics initially will be high and so the overall algorithm will approach a suitable level of accuracy more quickly.

In step S502, the vertical translation metric will be calculated using the value of roll. This will be explained later with reference to FIG. 6.

In step S503, the scale metric will be calculated using the calculated value of the vertical translation metric. This will be explained later with reference to FIG. 8.

In step S504, the roll metric will be calculated using the calculated value of the scale metric. This will be explained later with reference to FIG. 9.

As the metrics are calculated on an iterative basis, in step S505, the number of iterations of the metric calculation for one frame of video is determined. If the number of iterations is below a threshold value (for example 5), the algorithm is run again using the values calculated in the previous iteration as an initial value.

If the number of iterations is above a threshold, the algorithm is checked to confirm whether a steady state has been reached (step S506). This may be determined if the values of the metrics between iterations does not change by a threshold value such as 0.05%. If the metrics are a steady state, the metric values are output and the algorithm waits until it is required again, for example if the camera settings change as noted above.

Calculation of Vertical Translation Metric (Step S502 of FIG. 5)

FIG. 6 shows a flow diagram explaining the principle for determining the vertical translation metric.

As the optical axis is scale invariant, it is advantageous to calculate the vertical translation value relative to the optical axis of the image captured by the camera. In order to do this, the pixel positions determined by the correspondence determiner 220 need to be converted to pixel positions relative to the optical axis. FIG. 7 shows a method for converting the pixel positions into pixel positions relative to the optical axis. It should be noted that the dimensions in this Figure relate to a full HD signal, but in embodiments, the resolution may be less than this. In a conventional pixel labelling scheme, for a high definition image, the top left pixel position is defined as (0,0) and the bottom right pixel position is (1920, 1080). Therefore, in such a conventional system, the centre of the image (which is assumed to be the optical axis position as noted above) has a pixel position of (960,540). (see previous note) However, in embodiments of the invention, the centre of the image has a pixel position of (0,0). In order to convert the conventional pixel position of (400,400) to be relative to the optical axis, the distance between the pixel position and the centre of the image needs to be determined. From FIG. 7, it is apparent that conventional pixel position (400,400) is 560 pixels to the left of the optical axis and 140 pixels above the optical axis. Therefore, conventional pixel position (400,400) is pixel position (−560, 140) relative to the optical axis.

In order to determine the metric indicating the vertical translation metric, two feature positions from the left image are selected. Specifically, one feature position located below the optical axis and one feature position above the optical axis in the left hand image is selected (S602). In embodiments, these feature points are selected randomly, although the invention is not so limited. Also selected are the corresponding feature positions from the right hand image (S603).

After the points are selected, they are placed into Equation 6 below to determine the value of translation (S604).

$\begin{matrix} {T = \frac{{y\;{2_{l} \cdot R_{1}}} - {y\;{1_{l} \cdot R_{2}}}}{{y\; 1_{l}} + {y\; 2_{l}}}} & \lbrack 6\rbrack \end{matrix}$ Where R ₁ =x1_(r)·sin(±θ)+y1_(r)·cos(±θ) and R ₂ =x2_(r)·sin(±θ)+y2_(r)·cos(±θ)

where T is the value of the translation, y1_(r) is the y co-ordinate of the feature position in the second image, y2_(l) is the y co-ordinate of a further feature position in the first image; x1_(r) is the x co-ordinate of a feature position in the second image that corresponds to the feature position in the first image, y1_(r) is the y co-ordinate of the corresponding feature position in the second image, x2_(r) is the x co-ordinate of the corresponding further feature position in the second image and y2_(r) is the y co-ordinate of the corresponding further feature position in the second image.

A derivation of this formula is provided at the end of the description.

It should be noted here that the sign of the value of θ in the values of R₁ and R₂ is dependent upon the quadrant in which the feature point p1 and p2 lie. Specifically, if the feature point (or position) lies in the bottom right or top left quadrants, then the roll value is −θ. Alternatively, if the feature point lies in the bottom left or top right quadrants, the roll value is +θ. This is because the roll is measured relative to the optical axis.

After the translation for these points is determined, the number of calculated vertical translation metrics is incremented by 1 (step S605). This number is compared with a threshold value (step S606). If the number of calculated metric values is less than the threshold, then another two points are selected and the vertical translation metric algorithm is run again. In embodiments, the threshold value is 20, although any other value is anticipated.

If the number of calculated metric values is above the threshold then the calculated values are ordered from lowest to highest (step S607). The median value of the ordered list is then selected (step S608) and this is deemed to be the calculated metric value for step S502 of FIG. 5. This median metric value is output as the vertical translation metric and is fed to the scale metric algorithm (step S503 of FIG. 5). It should be noted that the median value may be selected directly from the derived values. In other words, there may be no need to order the metric values before selecting a median value. This applies to the calculation of the other metrics.

Calculation of Scale Metric (Step S503 of FIG. 5)

FIG. 8 shows a flow diagram explaining the principle for determining the Scale metric.

In step S801, the pixel positions determined in the correspondence determiner 220 are converted into pixel positions relative to the optical axis as explained with reference to FIG. 7.

In order to determine the scale metric, a feature position from the left image is selected (S802). In embodiments, the feature point is selected randomly, although the invention is not so limited. Also selected is the corresponding feature position from the right hand image (S803).

After the point is selected, it is placed into Equation 7 below to determine the value of scale (S804).

$\begin{matrix} {S = \frac{y_{l}}{{x_{r} \cdot {\sin\left( {\pm \theta} \right)}} + {{y_{r} \cdot {\cos\left( {\pm \theta} \right)}} \pm T}}} & \lbrack 7\rbrack \end{matrix}$

Where the sign of T, the translation metric, is dependent upon where the point is located; y_(l) is the y co-ordinate of feature position in the first image, y_(r) is the y co-ordinate of the feature position in the second image, x_(r) is the x co-ordinate of the feature position in the second image. If p is located above the optical axis, the value is +T, and where the point is located below the optical axis, the value is −T. Also, the sign of θ is dependent upon which quadrant point p is located in as noted later.

A derivation of this formula is also provided at the end of the description.

After the scale is determined, the number of calculated scale metrics is incremented by 1 (step S805). This number is compared with a threshold value (step S806). If the number of calculated metric values is less than the threshold, then another point is selected and the scale metric algorithm is run again. In embodiments, the threshold value is 20, although any other value is anticipated.

If the number of calculated metric values is above the threshold then the calculated values are ordered from lowest to highest (step S807). The median value of the ordered list is then selected (step S808) and this is deemed to be the calculated metric value for step S503 of FIG. 5. This median metric value is output as the scale metric and is fed to the roll metric algorithm (step S504 of FIG. 5).

Calculation of Roll Metric

FIG. 9 shows a diagram explaining the principle for determining the roll calculation.

In step S901, the pixel positions determined in the correspondence determiner 220 are converted into pixel positions relative to the optical axis as explained with reference to FIG. 7.

In order to determine the roll metric, two feature positions from the left image are selected. Specifically, one feature position located to the left of the optical axis and one feature position to the right of the optical axis in the left hand image is selected (S902). In embodiments, these feature points are selected randomly, although the invention is not so limited. Also selected are the corresponding feature positions from the right hand image (S903).

After the points are selected, they are placed into Equation 8 below to determine the value of translation (S904).

$\begin{matrix} {{\Delta\theta} = {{Tan}^{- 1}\left( \frac{R - L}{1 + {R \cdot L}} \right)}} & \lbrack 8\rbrack \end{matrix}$

Where

$R = {{\frac{\left( {{y\; 2_{r}} - {y\; 1_{r}}} \right)}{\left( {{x\; 2_{r}} - {x\; 1_{r}}} \right)}\mspace{14mu}{and}\mspace{14mu} L} = \frac{\left( {{y\; 2_{l}} - {y\; 1_{l}}} \right)}{S \cdot \left( {{x\; 2_{r}} - {x\; 1_{r}}} \right)}}$ and S is the scale metric

S is the scale misalignment between the first and second images, y2_(l) is the y co-ordinate of the further feature position in the first image, y1_(l) is the y co-ordinate of the feature position in the first image, y1_(r) is the y co-ordinate of the corresponding feature position in the second image, x2_(r) is the x co-ordinate of the corresponding further feature position in the second image and x1_(r) is the x co-ordinate of the corresponding feature position in the second image.

A derivation of this formula is provided at the end of the description.

After the roll for these points is determined, the number of calculated roll metrics is incremented by 1 (step S905). This number is compared with a threshold value (step S906).

If the number of calculated metric values is less than the threshold, then another two points are selected and the roll metric algorithm is run again. In embodiments, the threshold value is 20, although any other value is anticipated.

If the number of calculated metric values is above the threshold then the calculated values are ordered from lowest to highest (step S907). The median value of the ordered list is then selected (step S908) and this is deemed to be the calculated metric value for step S504 of FIG. 5. This median metric value is output as the roll metric.

If, in step S505 or S506, the metric calculation algorithm is run again, the value of roll calculated in step S908 is used in the next iteration. However, if the metric calculation algorithm is not run again, the roll metric calculated in step S908, as well as the vertical translation metric from step S608 and the scale metric from step S808 are output as the results of the metric calculation algorithm.

Other Embodiments

In the above a steady state is noted. It should be noted that this is not essential to the invention. A single iteration of the algorithm will indicate a level of mismatch allowing for correction to take place. Indeed, any number of iterations will identify an amount of mismatch.

Embodiments of the present invention may be provided as computer readable instructions which when loaded onto a computer, configure the computer to perform the embodied method. The computer readable instructions may be written in any computer readable language or indeed any language that can be understood by an appropriate microprocessor. The computer program may be stored on a recording medium such as a magnet disc, or optical disc or any solid-state memory. Further the computer program may exist as a carrier on a network, such as the Internet.

Although the above notes the conversion of the pixels to be relative to the optical axis of the image in each individual algorithm, the invention is not so limited. Indeed, the conversion may take place after the correspondence points are calculated and before the feature points are passed to the metric calculator 230. This would reduce the computational burden in the metric calculator 230. Moreover, in the same and other embodiments, only the selected pixel positions used in each algorithm will be converted to be relative to the optical axis. In other words, only after the points are selected to calculate a metric are they converted.

Although the foregoing has been described with the different metrics being calculated in a particular order, the invention is not so limited. The metrics may be calculated in any order.

Although the foregoing has been described with the metrics being obtained from a high definition image, the invention is not so limited. For example, the metrics could be obtained from a standard definition image, or from a reduced scale version of the high definition image. For example, the metrics could be obtained from a 4:1 reduction in scale. In this case, one pixel in the reduced image is formed of four pixels in the high definition image. In this situation, the actual pixel value for the reduced image could be selected from the four possible pixel values in the high definition image. Such selection may be made randomly.

Further, in the case that the misalignment metric value or values indicate that the error is not an integer pixel value, then the nearest integer pixel value above and below the misalignment value may be displayed to the user so that they can select which pixel they wish to use, or may even select the nearest pixel value rounded to the nearest integer.

Although illustrative embodiments of the invention have been described in detail herein with reference to the accompanying drawings, it is to be understood that the invention is not limited to those precise embodiments, and that various changes and modifications can be effected therein by one skilled in the art without departing from the scope and spirit of the invention as defined by the appended claims.

Derivation of Translation Metric

Referring to FIG. 10, given two points p1, described by the coordinate pair (x1, y1) and p2, described by the coordinate pair (x2, y2) we can express the position of y1_(l) and y2_(l) in terms of rotation, translation and scaling of the points y1_(r) and y2_(r).

Given that y1_(l) lies above the optical axis, it can be described as: y1_(l) =S(x1_(r)·sin(θ)+y1_(r)·cos(θ)−T)  [15]

Given that y2_(l) lies below the optical axis, it can be described as: y2_(l) =S(x2_(r)·sin(−θ)+y2_(r)·cos(−θ)+T)  [16]

where S is the constant describing scale and T the constant describing vertical translation.

From [15], for the point p1 above the optical axis:

$\begin{matrix} {S = {{\frac{y\; 1_{l}}{\left( {R_{1} - T} \right)}\mspace{14mu}{where}\mspace{14mu} R_{1}} = {{x\;{1_{r} \cdot {\sin(\theta)}}} + {y\;{1_{r} \cdot {\cos(\theta)}}}}}} & \lbrack 17\rbrack \end{matrix}$

And from [16], for the point p2 below the optical axis:

$\begin{matrix} {S = {{\frac{y\; 2_{l}}{\left( {R_{2} + T} \right)}\mspace{14mu}{where}\mspace{14mu} R_{2}} = {{x\;{2_{r} \cdot {\sin\left( {- \theta} \right)}}} + {y\;{2_{r} \cdot {\cos\left( {- \theta} \right)}}}}}} & \left\lbrack 18 \right\} \end{matrix}$

Because S is equivalent in [17] and [18] it follows that:

$\frac{y\; 1_{r}}{\left( {R_{1} - T} \right)} = \frac{y\; 2_{l}}{\left( {R_{2} + T} \right)}$ y 1_(r)(R₂ + T) = y 2_(l)(R₁ − T) R₂ ⋅ y 1_(l) + T ⋅ y 1_(r) = R₁ ⋅ y 2_(l) − T ⋅ y 2_(l) T(y 1_(l) + y 2_(l)) = R₁y 2_(l) − R₂y 1_(l) $T = \frac{\left( {{{R_{1} \cdot y}\; 2_{l}} - {{R_{2} \cdot y}\; 1_{l}}} \right)}{\left( {{y\; 1_{l}} + {y\; 2_{l}}} \right)}$ Derivation of Scale Metric

From equations [17] and [18] above, it can be seen that the scale, S can be calculated as follows.

$S = \frac{y\; 1_{l}}{\left( {R_{1} - T} \right)}$ where R₁=x1_(r)·sin(θ)+y1_(r)·cos(θ) for a point located above the optical axis and

$S = \frac{y\; 2_{l}}{\left( {R_{2} + T} \right)}$ where R₂=x2_(r)·sin(−θ)+y2_(r)·cos(−θ) for a point located below the optical axis.

This can be generalised as

$S = \frac{y_{l}}{{{x_{r} \cdot {\sin\left( {\pm \theta} \right)}} + {{y_{r} \cdot {\cos\left( {\pm \theta} \right)}} \pm T}}\;}$

Where the sign of T, the translation metric, is dependent upon where the point is located; if p is located above the optical axis, the value is +T, and where the point is located below the optical axis, the value is −T. Also, the sign of θ is dependent upon which quadrant point p is located.

Derivation of Roll Metric

Referring to FIG. 11 which shows the selection of points used for rotation calculation and FIG. 12 that shows the measuring of angles based on the vertical position, random key feature positions are selected, one selected from the left hand side of the optical axis (p1), and one selected from right hand side of the optical axis (p2).

To measure the relative rotation of the points p1 and p2 it is necessary to determine the gradient between p1_(l) and p2_(l), and compare it to the gradient between p1_(r) and p2_(r). In other words, compare the gradient between the two points in the left hand image, and the gradient between the corresponding points in the right hand image. It should be noted that the rotation calculation is invariant to Translation, but not to Scale. Therefore Scale (S) is accounted for within the calculation.

The gradient between p1_(r) and p2_(r) is calculated as:

$\begin{matrix} {{{Tan}\left( \theta_{r} \right)} = \frac{\left( {{y\; 2_{r}} - {y\; 1_{r}}} \right)}{\left( {{x\; 2_{r}} - {x\; 1_{r}}} \right)}} & \lbrack 19\rbrack \end{matrix}$

If we assumed no vertical parallax, and only effects due to scale (S) i.e.

${y\; 1_{r}} = {{\frac{y\; 1_{l}}{S}\mspace{14mu}{and}\mspace{14mu} y\; 2_{r}} = \frac{y\; 2_{l}}{S}}$ then the gradient without parallax would be

$\begin{matrix} {{{Tan}\left( \theta_{l} \right)} = \frac{\left( {{y\; 2_{l}} - {y\; 1_{l}}} \right)}{S \cdot \left( {{x\; 2_{r}} - {x\; 1_{r}}} \right)}} & \lbrack 20\rbrack \end{matrix}$

If we express [19] as:

Tan(θ_(r))=R where

$R = \;\frac{\left( {{y\; 2_{r}} - {y\; 1_{r}}} \right)}{\left( {{x\; 2_{r}} - {x\; 1_{r}}} \right)}$

And [20] as:

Tan(θ_(l))=L where

$L = \frac{\left( {{y\; 2_{l}} - {y\; 1_{l}}} \right)}{S \cdot \left( {{x\; 2_{r}} - {x\; 1_{r}}} \right)}$

Then the actual angle of the roll metric can be calculated as: Δθ=Tan⁻¹(R)−Tan⁻¹(L)

Given the trigonometric identity:

${{{Tan}^{- 1}(\alpha)} - {{Tan}^{- 1}(\beta)}} = {{Tan}^{- 1}\left( \frac{\alpha - \beta}{1 + {\alpha \cdot \beta}} \right)}$

We can express the roll metric as:

${\Delta\;\theta} = {{Tan}^{- 1}\left( \frac{R - L}{1 + {R \cdot L}} \right)}$ 

We claim:
 1. A method of determining misalignment between a first image and a second image, the first and second images being viewable stereoscopically, the method comprising: determining a feature position within the first image and a corresponding feature position within the second image; defining, within the first image and the second image, the optical axis of the cameras capturing said respective images; calculating the misalignment between the feature position within the first image and the corresponding feature position within the second image using a model, the misalignment being determined in dependence upon the location of the feature position of the first image and the corresponding feature position of the second image relative to the defined optical axis of the respective images; and testing the validity of the calculated misalignment using a random sample consensus technique, whereby the tested misalignment is valid when the random sample consensus technique achieves a predetermined condition, wherein the model is defined by the equation y=S·(xL·sin θ+yL·cos θ)+T where y is a vertical position of the feature point in the second image; xL and yL are respective horizontal and vertical positions of the feature point in the first image; θ is a roll angle; S is a scale metric and T is a vertical mismatch metric between the two images.
 2. The method according to claim 1, wherein the misalignment is valid when the probability of the correct misalignment is above a threshold.
 3. The method according to claim 1, wherein the predetermined condition is a predetermined number of iterations of the random sample consensus technique.
 4. The method according to claim 3, wherein the number of iterations is determined according to the equation $n = \frac{\log\left( {1 - {{target\_ incorrect}{\_ est}{\_ prob}}} \right)}{\log\left( {1 - {incorrect} - {est\_ prob}} \right)}$ Where target_incorrect_est_prob is the probability of the model being incorrect and incorrect_est_prob is probability of the corresponding feature point being incorrect.
 5. The method according to claim 1, further comprising: obtaining feature points from downscaled versions of an original first and second image using a block match technique.
 6. The method according to claim 5, further comprising: using the feature points obtained from the downscaled versions of the original first and second image as a starting point for a block match technique in the original first and second image and obtaining the first and second feature points from the original first and second image.
 7. The method according to claim 1, further comprising: defining within the first image at least one further feature position, and at least one further corresponding feature position within the second image, wherein the vertical mismatch is calculated by: selecting two feature positions in the first image and a corresponding two feature positions within the second image; and determining the vertical mismatch in accordance with a given roll misalignment between the first and second images.
 8. The method according to claim 7, wherein the feature position in the first image and the corresponding feature position in the second image are located above the defined optical axis and the further feature position in the first image and the corresponding feature position in the second image are located below the defined optical axis.
 9. The method according to claim 7, wherein the feature position and the further feature position are generated randomly.
 10. The method according to claim 1, wherein the scale metric is calculated by: selecting a feature position in the first image and a corresponding feature position within the second image; and determining the scale metric in accordance with a given vertical translation between the first and second images.
 11. The method according to claim 10, wherein the feature position in the first image and the corresponding feature position in the second image is located above the defined optical axis or the feature position in the first image and the corresponding feature position in the second image is located below the defined optical axis.
 12. The method according to claim 1, further comprising: defining within the first image at least one further feature position, and at least one further corresponding feature position within the second image, wherein the roll angle is calculated by: selecting two feature positions in the first image and a corresponding two feature positions within the second image; and determining the roll angle in accordance with a given scale misalignment between the first and second images.
 13. The method according to claim 12, wherein the feature position in the first image and the corresponding feature position in the second image are located to the left of the defined optical axis and the further feature position in the first image and the corresponding feature position in the second image are located to the right of the defined optical axis.
 14. The method according to claim 1, wherein the feature position is a pixel position in the respective first and second image.
 15. A non-transitory computer-readable medium storing a computer program containing computer readable instructions which, when loaded onto a computer, configure the computer to perform a method according to claim
 1. 16. An apparatus for determining misalignment between a first image and a second image, the first and second images being viewable stereoscopically, the apparatus comprising: circuitry configured to: determine a feature position within the first image and a corresponding feature position within the second image; define, within the first image and the second image, the optical axis of the cameras capturing said respective images; calculate the misalignment between the feature position within the first image and the corresponding feature position within the second image using a model, the misalignment being determined in dependence upon the location of the feature position of the first image and the corresponding feature position of the second image relative to the defined optical axis of the respective images; and test the validity of the calculated misalignment using a random sample consensus technique, whereby the tested misalignment is valid when the random sample consensus technique achieves a predetermined condition, wherein the model is defined by the equation y=S·(xL·sin θ+yL·cos θ)+T where y is the vertical position of the feature point in the second image; xL and yL are the respective horizontal and vertical positions of the feature point in the first image; θ is the roll angle; S is the scale metric and T is the vertical mismatch metric between the two images.
 17. The apparatus according to claim 16, wherein the misalignment is valid when the probability of the correct misalignment is above a threshold.
 18. The apparatus according to claim 16, wherein the predetermined condition is a predetermined number of iterations of the random sample consensus technique.
 19. The apparatus according to claim 18, wherein the number of iterations is determined according to the equation $n = \frac{\log\left( {1 - {{target\_ incorrect}{\_ est}{\_ prob}}} \right)}{\log\left( {1 - {incorrect} - {est\_ prob}} \right)}$ Where target_incorrect_est_prob is the probability of the model being incorrect and incorrect_est_prob is probability of the corresponding feature point being incorrect.
 20. The apparatus according to claim 16, wherein the circuitry is further configured to obtain feature points from downscaled versions of an original first and second image using a block match technique.
 21. The apparatus according to claim 20, wherein the circuitry is further configured to use the feature points obtained from the downscaled versions of the original first and second image as a starting point for a block match technique in the original first and second image and obtain the first and second feature points from the original first and second image.
 22. The apparatus according to claim 16, wherein the circuitry is further configured define within the first image at least one further feature position, and at least one further corresponding feature position within the second image, wherein the vertical mismatch is calculated by: selecting two feature positions in the first image and a corresponding two feature positions within the second image; and determining the vertical mismatch in accordance with a given roll misalignment between the first and second images.
 23. The apparatus according to claim 22, wherein the feature position in the first image and the corresponding feature position in the second image are located above the defined optical axis and the further feature position in the first image and the corresponding feature position in the second image are located below the defined optical axis.
 24. The apparatus according to claim 22, wherein the feature position and the further feature position are generated randomly.
 25. The apparatus according to claim 16 wherein the scale metric is calculated by: selecting a feature position in the first image and a corresponding feature position within the second image; and determining the scale metric in accordance with a given vertical translation between the first and second images.
 26. The apparatus according to claim 25, wherein the feature position in the first image and the corresponding feature position in the second image is located above the defined optical axis or the feature position in the first image and the corresponding feature position in the second image is located below the defined optical axis.
 27. The apparatus according to claim 16, wherein the circuitry is further configured to define within the first image at least one further feature position, and at least one further corresponding feature position within the second image, wherein the roll angle is calculated by: selecting two feature positions in the first image and a corresponding two feature positions within the second image; and determining the roll angle in accordance with a given scale misalignment between the first and second images.
 28. The apparatus according to claim 27, wherein the feature position in the first image and the corresponding feature position in the second image are located to the left of the defined optical axis and the further feature position in the first image and the corresponding feature position in the second image are located to the right of the defined optical axis.
 29. The apparatus according to claim 16, wherein the feature position is a pixel position in the respective first and second image. 